package com.ezregex;

import java.util.Collections;
import java.util.List;

public class RegexBuilder {

    private RegexBuilder() {
    }

    public static RepetitionStep aRegexContaining() {
        return new Steps();
    }

    public static interface RepetitionStep {

        FollowedBy once(String content);

        CardinalityStep exactly(int times, String content);

        FollowedBy moreThanOnce(String content);

    }

    public static interface CardinalityStep {
        FollowedBy times();
    }

    public static interface FollowedBy {

        RepetitionStep followedBy();

        BuildStep endRegex();

    }

    public static interface BuildStep {

        public String build();

    }

    public static String literal(String literal) {
        return literal;
    }

    public static String oneOf(List<CharacterClasses> regexCharacterClasses, String... character) {
        String characterSequence = "[";

        for (CharacterClasses characterClasses : regexCharacterClasses) {
            characterSequence += characterClasses.getRegexClassType();
        }

        for (String userClassType : character) {
            characterSequence += userClassType;
        }

        characterSequence += "]";

        return characterSequence;
    }

    public static String oneOf(String... character) {
        return oneOf(emptyList(), character);
    }

    private static List<CharacterClasses> emptyList() {
        return Collections.emptyList();
    }

}
